package EmailService;

import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;


public class MyAuthenticator extends Authenticator{

    // 用户名和密码
    private String userName;
    private String userPassword;

    /**
     * 初始化邮箱地址和密码
     * @param userName 邮箱地址
     * @param userPassword 密码
     */
    public MyAuthenticator(String userName,String userPassword){
        this.userName = userName;
        this.userPassword = userPassword;
    }

    /**
     * 重写自我检验方法
     * @return PasswordAuthentication对象
     */
    @Override
    protected PasswordAuthentication getPasswordAuthentication(){
        return new PasswordAuthentication(userName,userPassword);
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserPassword() {
        return userPassword;
    }

    public void setUserPassword(String userPassword) {
        this.userPassword = userPassword;
    }
}
